package cn.com.miao.lynx.common.log.envnt;

import cn.com.miao.lynx.common.log.api.LogDetail;
import cn.com.miao.lynx.common.log.api.RemoteLogService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;

/**
 * LogListener
 * 异步日志监听器
 * @title: LogListener
 * @description: 异步日志监听器
 * @author: dengmiao
 * @create: 2019-12-27 11:30
 **/
@Slf4j
@AllArgsConstructor
public class LogListener {

    private final RemoteLogService remoteLogService;

    @Async
    @Order
    @EventListener(LogEvent.class)
    public void saveSysLog(LogEvent event) {
        LogDetail logDetail = (LogDetail) event.getSource();
        remoteLogService.save(logDetail);
    }
}
